﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Pinballs : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        
        if (!Page.IsPostBack)
        {
            sel_tour.DataSource = Tournament.getAvailableTournaments();
            sel_tour.DataTextField = "Tournament_Name";
            sel_tour.DataValueField = "Pk_Tournament";
            sel_tour.DataBind();

            if (sel_tour.Items.Count > 0)
            {
                PinballList.DataSource = Machine.GetMachinesByTournament(Int32.Parse(sel_tour.SelectedValue));
                PinballList.DataBind();
            }
        }
        AjaxPro.Utility.RegisterTypeForAjax(typeof(Pinballs));
    }



    protected void sel_tour_SelectedIndexChanged(object sender, EventArgs e)
    {
        PinballList.DataSource = Machine.GetMachinesByTournament(Int32.Parse(sel_tour.SelectedValue));
        PinballList.DataBind(); 
    }
}
